<?php

//var_dump($GLOBALS);
require_once(dirname(__FILE__) . "/common/lib/search_tools.php");

main();

function main()
{
	//var_dump($_GET);	
		
	# 前置判断
	if(!empty($_REQUEST['getclientip']))
	{
		$client_ip = $_SERVER['HTTP_HOST'];
		echo $client_ip;
		return 0;
	}
	if($_REQUEST['tool_selected']==null || $_REQUEST['tool_content']==null)
	{
		echo "输入错误，请重新输入";
		die();
	}

	
	$return_data="";

	switch($_REQUEST['tool_selected'])
	{
		case "phone_114":
			$return_data = phone_114($_REQUEST['tool_content']);
			break;
		case "phone_location":
			$return_data = locate_phone($_REQUEST['tool_content']);
			break;
		case "idcard_location":
			$return_data = locate_idcard($_REQUEST['tool_content']);
			break;
		case "ip_location":
			$return_data = locate_ipaddr($_REQUEST['tool_content']);
			break;
		default:
			$return_data = "选择错误，请重新输入";
	}

	echo $return_data;
}

# 114 查询
function phone_114($data)
{
	echo "phone_114 is doing...";
	
}

function locate_phone($data)
{
	$st = new SearchTools($data);
	
	$st->locatePhoneaddr();
	echo $st->getResult();
	
}

function locate_idcard($data)
{
	$st = new SearchTools($data);
	
	$st->locateIDCard();
	echo $st->getResult();
	
}

// 查询ip地址所属地
function locate_ipaddr($data)
{
	$st = new SearchTools($data);
	
	$st->locateIpaddr();
	echo $st->getResult();
}

?>